<include file="public:header" />
<!--菜单添加-->
<ul id="mytab" class="nav nav-tabs" style="margin-top: 15px;">
    <li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
    <li class="active"><a href="#con1" data-toggle="tab">菜单编辑</a></li>
</ul>
<div id="tabContent" class="tab-content">
    <div class="tab-pane fade in active" id="con1">
        <div style="margin-top: 20px;">
            <form class="form-horizontal" role="form" action="{:u('superadmin/menu/edit')}" method="post">

                <div class="form-group">
                    <label class="col-sm-1 control-label label-form">父级菜单:</label>
                    <div class="col-sm-3 input-padding">
                        <select class="form-control" name="pid">
                            <option value="0">{:L('no_parent_menu')}</option>
                            {$select_menus}
                        </select>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-1 control-label label-form">菜单名称:</label>
                    <div class="col-sm-3 input-padding">
                        <input type="text" class="form-control" value="{$menu.name}" name="menuname" id="menuname"
                               placeholder="请输入菜单名称">
                    </div>
                </div>

                <!--<div class="form-group">-->
                    <!--<label class="col-sm-1 control-label label-form">模块名称:</label>-->
                    <!--<div class="col-sm-3 input-padding">-->
                        <!--<input type="text" value="superadmin" class="form-control" id="module_name"-->
                               <!--placeholder="请输入模块名称">-->
                    <!--</div>-->

                <!--</div>-->

                <div class="form-group">
                    <label class="col-sm-1 control-label label-form">控制器名称:</label>
                    <div class="col-sm-3 input-padding">
                        <input type="text" class="form-control" value="{$menu.module_name}" name="controlname" id="control_name"
                               placeholder="请输入控制器名称 如：menu">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-1 control-label label-form">方法名称:</label>
                    <div class="col-sm-3 input-padding">
                        <input type="text" class="form-control" value="{$menu.action_name}" name="actionname" id="action_name"
                               placeholder="请输入方法名称 如：add">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-1 control-label label-form">附加参数:</label>
                    <div class="col-sm-3 input-padding">
                        <input type="text" class="form-control" value="{$menu.data}" name="data" id="addons"
                               placeholder="">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-1 control-label label-form">排序:</label>
                    <div class="col-sm-1 input-padding" style="width: 100px;">
                        <input type="text" class="form-control" name="ordid" value="{$menu.ordid}" id="ordid"
                               placeholder="">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-1 control-label label-form">说明:</label>
                    <div class="col-sm-3 input-padding">
                        <textarea class="form-control" name="remark" rows="3">{$menu.remark}</textarea>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-1 control-label label-form">是否显示:</label>
                    <label class="checkbox-inline">
                        <input type="radio" name="display"  value="1" <if condition="$menu.display eq 1"> checked="checked" </if>> 是
                    </label>
                    <label class="checkbox-inline">
                        <input type="radio" name="display" value="0" <if condition="$menu.display eq 0"> checked="checked" </if>> 否
                    </label>
                </div>

                <div class="form-group">
                    <button id="save" class="btn btn-primary btn-position">保存</button>
                </div>
                <input type="hidden" name="menuid" value="{$menu.id}">
            </form>

        </div>
    </div>
    <!--<div class="tab-pane fade" id="con2">-->
        <!--code-->
    <!--</div>-->
</div>


<include file="public:footer" />
<script>
$(document).ready(function(){
    $('#mytab a').click(function (e) {
        e.preventDefault()
        $(this).tab('show')
    })

    $('#save').click(function(){
        var menuname     = $.trim($('#menuname').val());
        var controlname = $.trim($('#control_name').val());
        var actionname  = $.trim($('#action_name').val());


        if(!menuname)
        {
            $('#menuname').val('').focus();
            layer.tips('请输入菜单名称', '#menuname', {
                tips: [2, '#009f95'],
                time: 3000
            });
            return false;
        }
        if(!controlname)
        {
            $('#control_name').val('').focus();
            layer.tips('请输入控制器名称', '#control_name', {
                tips: [2, '#009f95'],
                time: 3000
            });
            return false;
        }
        if(!actionname)
        {
            $('#action_name').val('').focus();
            layer.tips('请输入方法名称', '#action_name', {
                tips: [2, '#009f95'],
                time: 3000
            });
            return false;
        }

        //数据验证
        $.ajax({
            type: "POST",
            url: $('.form-horizontal').attr('action'),
            data: $('.form-horizontal').serialize(),
            dataType: "json",
            success:function(data){
                if(data.status)
                {
                    layer.msg(data.msg,{icon: 1,time:2000, shade: [0.1, '#ccc']},function(){
                        window.location.href="{:u('superadmin/menu/getlist')}";
                    })
                } else {
                    layer.msg(data.msg,{icon: 2,time:2000, shade: [0.1, '#ccc']})
                }

            }
        });
        return false;
    });



});
</script>
</body>
</html>